package org.standard.commons.service;

import java.io.File;
import java.sql.SQLException;
import java.util.List;

import javax.servlet.http.HttpServletRequest;

import org.apache.commons.fileupload.FileUploadException;
import org.standard.commons.utils.FlipPageInfo;
import org.standard.proposal.model.Proposal;


public interface Service{
	
	public Object findPOJOById(Class classPOJO, String id);
	
	public void createPOJO(Object beo);
	
	public void modifyPOJO(Object beo);
	
	public void deletePOJO(Object beo);
	
	public void deletePOJO(Class classPOJO, String id);
	
	public void deleteCascadePOJO(Class classParent, String[][] classChild, String id) throws SQLException;
	
	public FlipPageInfo findPOJOList(Class classPOJO, 
			FlipPageInfo flipPageInfo);
	
	public FlipPageInfo findPOJOList(Class classPOJO,
			FlipPageInfo flipPageInfo, String[][] search);
	/**
	 * 以应急项目为例
	 * @param classPOJO 要查询的表对应的POJO 例如：Yjxm.class
	 * @param flipPageInfo 分页类
	 * @param search 查询条件 根据传入参数进行模糊查询
	 * 				例如：String [][]search = {
							{"yjxm", yjxm.getYjxm()},
							{"yjcl", yjxm.getYjcl()}
						};
						二维数组，左侧对应表对应的POJO中要查询的字段名字，右侧对应值
	 * @param sort 排序条件 根据传入参数进行升降序
	 * 				例如：String [][]sort = {
							{"yjxm", "0"},
							{"yjcl", "1"}
						};
						二维数组，左侧对应表对应的POJO中要查询的字段名字，右侧只能为0【升序】,1【降序】
	 * @return
	 */
	public FlipPageInfo findPOJOList(Class classPOJO, 
			FlipPageInfo flipPageInfo, String[][] search, String[][] sort);
	
	public FlipPageInfo findPOJOList(String sql, 
			FlipPageInfo flipPageInfo);
	/**
	 * 统计数据专用
	 * @param classPOJO 要统计的对象
	 * @param counts 统计字段
	 * @param groupBy 根据该字段统计
	 * @return
	 */
	public List findPOJOList(Class classPOJO, String[] select, String[][] search, String[] groupBy);
	
	public List findPOJOList(String sql);
	
	public FlipPageInfo findPOJOList(String[] select, Class[] classPOJO, 
			FlipPageInfo flipPageInfo, String[][] search, String[][] sort);
	
	public void modifyMergePOJO(Object beo);
	
	public FlipPageInfo findWithPagingBySql(String sql, FlipPageInfo flipPageInfo);
	
	public List findPOJOListBySql(String sql);
	
	public void createPOJOAndAnnex(Object beo, HttpServletRequest request, 
			File[] annex, String[] annexFileName, String[] annexContentType) throws FileUploadException;
	
	public void deletePOJOCascadeAnnex(Object beo, String id) throws SQLException;
	
	public void modifyPOJOAndAnnex(Object beo, HttpServletRequest request,
			File[] annex, String[] annexFileName, String[] annexContentType , String id) throws FileUploadException, SQLException;

	void createPOJOAndAnnex(Object beo, HttpServletRequest request,
			String annex, String annexFileName) throws FileUploadException;

	void modifyPOJOAndAnnex(Object beo, HttpServletRequest request,
			String annex, String annexFileName, String id, String saveName)
			throws FileUploadException, SQLException;

}

